<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>消息弹框</title>
    <link rel="stylesheet" href="res/css/message.css" />
    <style>
      body {
        width: 740px;
        overflow-x: hidden;
      }

      .content {
        word-wrap: break-word;
        white-space: pre-wrap;
        word-break: break-all;
        padding: 0 18px;
      }

      .content {
        -ms-overflow-style: none;
        scrollbar-width: none;
      }

      .content::-webkit-scrollbar {
        display: none;
      }
    </style>
    <script src="res/js/qwebchannel.js"></script>
    <script src="res/js/messageId.js"></script>
  </head>

  <body>
    <div class="popup-header"></div>
    <div class="message-body">
      <div class="info">
        <span class="time" id="sendTime"></span>
        <span class="dept-user" id="sendUser"></span>
      </div>
      <div class="content" id="msg-content"></div>
    </div>
  </body>
  <script src="res/js/contextMenu.js"></script>
  <script>
    // 数据接收函数
    var SignalJsResponse = function (json) {
      let res = JSON.parse(json) || {};
      document.getElementById("sendTime").innerText = res.SendTime;
      document.getElementById("sendUser").innerText = res.SendUser;
      document.getElementById("msg-content").innerHTML = res.Content;
      // 匹配img，传过来的图片地址都不全，暂时隐藏
      let imgElementList = document.getElementsByTagName("img");
      for (let index = 0; index < imgElementList.length; index++) {
        const element = imgElementList[index];
        element.style.display = "none";
      }
    };
    // 调用C++
    new QWebChannel(qt.webChannelTransport, function (channel) {
      var webobj = channel.objects.message_dlg_object;
      window.msg_dlg = webobj;
      window.msg_dlg.SignalJsResponse.connect(SignalJsResponse); // c++返回内容
      let messageID = GetQueryString("MessageID");
      let data = {
        cmd: "MainwtMessageDetailReq",
        MessageID: messageID,
      };
      msg_dlg.SlotJsRequest(JSON.stringify(data)); // 向c++发送请求
    });
  </script>
</html>
